package com.kaoshi.myweb.dependent.entity;

import java.lang.reflect.Field;

/**
 * Created by Administrator on 2017/2/26.
 */
public class DynaicCompileParent {
	public String id;

	public String name;

	//方便反射对象，设置值
	public void setFieldValue(String fieldName, Object fieldValue){
		Field field = null;
		try {
			field = this.getClass().getDeclaredField(fieldName);
			field.set(this, fieldValue);
		} catch (NoSuchFieldException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
	}

	//方便反射对象，获取值
	public Object getFieldValue(String fieldName){
		Field field = null;
		try {
			field = this.getClass().getDeclaredField(fieldName);
			return field.get(this);
		} catch (NoSuchFieldException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}

		return null;
	}
}
